import { Affix } from 'antd';
import { connect } from 'react-redux';
import { onlineService } from '@/components/ToolBar/toolbar';
// css
import styles from '@/styles/CommonOrder.module.scss';

const Aside = function ({ data: { goodsName }, order: { price, salePrice, reducePrice } }) {
    if(!goodsName){
        return <></>
    }
    return (
        <div className={styles['aside']}>
            <Affix offsetTop={10}>
                <div>
                    <div className={styles['aside-info']}>
                        <h3>{goodsName}</h3>
                        <div className={styles['aside-total']}>
                            <span>费用合计</span>
                            <em><i>￥</i>{salePrice}</em>
                        </div>
                        {
                            reducePrice
                            ? <div className={styles['aside-reduce']}>
                                <span>优惠金额</span>
                                <em><i>￥</i>{reducePrice}</em>
                              </div>
                            : ""
                        }
                        <div className={styles['aside-pay']}>
                            <span>实际支付</span>
                            <em><i>￥</i>{price}</em>
                        </div>
                    </div>
                    <div className={styles['aside-kf']}>
                        <div className={styles['phone']}>
                            17302869470 <br />
                            &nbsp;(9:00-22:00)
                        </div>
                        <div className={styles['online']}>
                            <span className="iconfont icon-kefu"></span>
                            <h5>客服在线</h5>
                            <div onClick={() => { onlineService(goodsName) }}>点击与客服对话</div>
                        </div>
                    </div>
                </div>
            </Affix>
        </div>
    )
}
const mapDispatchToProps = (state) => {
    return {
        order: state.order
    }
}
export default connect(mapDispatchToProps, null)(Aside)